home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / fract / FlashMandel.lha / FlashMandel / Sources / Modules / MandReal.S < prev    next >
Text File  |  1999-01-22  |  4KB  |  102 lines

  1. ************************************************************************
  2. **            Written by Dino Papararo            23-Sep-1998
  3. **
  4. **  FUNCTION
  5. **
  6. **    MandReal -- perform Z = Z^2 + C iteration.
  7. **
  8. **  SYNOPSIS
  9. **
  10. **    WORD MandFPU (WORD Iterations,long double Cre,long double Cim)
  11. **
  12. **
  13. **  DESCRIPTION
  14. **
  15. **  C equivalent function:
  16. **
  17. **    ***************************************************************
  18. **    *WORD Real (WORD Iterazioni,long double Cre,long double Cim)***
  19. **    *{                                                          ***
  20. **    *register long double zr,zi,zi2,dist,maxdist;               ***
  21. **    *                                                           ***
  22. **    *  zi = Cim;                                                ***
  23. **    *                                                           ***
  24. **    *  zr = Cre;                                                ***
  25. **    *                                                           ***
  26. **    *  maxdist = 4;                                             ***
  27. **    *                                                           ***
  28. **    *  do {                                                     ***
  29. **    *       zi2 = zi;                                           ***
  30. **    *                                                           ***
  31. **    *       zi  *= zr;                                          ***
  32. **    *                                                           ***
  33. **    *       zr  *= zr;                                          ***
  34. **    *                                                           ***
  35. **    *       zi2 *= zi2;                                         ***
  36. **    *                                                           ***
  37. **    *       dist = zr;                                          ***
  38. **    *                                                           ***
  39. **    *       dist += zi2;                                        ***
  40. **    *                                                           ***
  41. **    *       if (dist > maxdist) return Iterazioni;              ***
  42. **    *                                                           ***
  43. **    *       zi += zi;                                           ***
  44. **    *                                                           ***
  45. **    *       zr -= zi2;                                          ***
  46. **    *                                                           ***
  47. **    *       zi += Cim;                                          ***
  48. **    *                                                           ***
  49. **    *       zr += Cre;                                          ***
  50. **    *                                                           ***
  51. **    *     } while (-- Iterazioni);                              ***
  52. **    *                                                           ***
  53. **    *  return 0;                                                ***
  54. **    *}                                                          ***
  55. **    ***************************************************************
  56. **
  57. **  This function tests if a point belongs or not at mandelbrot's set
  58. **
  59. **  Optimized for pipelines of 68882+ coprocessors
  60. **
  61. **  NOTICE: ALL VARIABLES ARE INTO REGISTERS FOR FULL SPEEEED
  62. **
  63. **  d0:Iterations
  64. **
  65. **  fp0:Cre fp1:Cim fp2:Zr fp3:Zi fp4:Zi2 fp5:Dist fp6:MaxDist
  66. ************************************************************************
  67.  
  68.  
  69.  
  70.         XDEF  _MandFPU
  71.  
  72. _MandFPU:
  73.  
  74.  
  75.         fmove.x fp1,fp3  * Zi = Cim
  76.         fmove.x fp0,fp2  * Zr = Cre
  77.         fmove.b #4,fp6   * MaxDist = 4
  78.  
  79. Loop:
  80.  
  81.         fmove.x fp3,fp4  * zi2  =  zi
  82.         fmul.x  fp2,fp3  * zi   =  zr * zi
  83.         fmul.x  fp2,fp2  * zr   =  zr * zr
  84.         fmul.x  fp4,fp4  * zi2 *=  zi
  85.         fmove.x fp2,fp5  * dist =  zr
  86.         fadd.x  fp4,fp5  * dist += zi2
  87.         fcmp.x  fp6,fp5  * cmp  MaxDist  dist
  88.         fbgt.w  Exit     * if   dist > MaxDist  exit
  89.         fadd.x  fp3,fp3  * zi   += zi
  90.         fsub.x  fp4,fp2  * zr   -= zi2
  91.         fadd.x  fp1,fp3  * zi   += Cim
  92.         fadd.x  fp0,fp2  * zr   += Cre
  93.  
  94.         dbra.w  d0,Loop  * if --Iterations go to Loop
  95.         moveq.l #0,d0    * Iterations = 0
  96.  
  97. Exit:
  98.  
  99.         rts  * return Iterations
  100.  
  101.         end
  102.